package Z03JiHeKuangJia.QiTaJiHe.T01Lianbiao;

import java.util.LinkedList;
import java.util.Queue;

public class LianBiao {
    public static void main(String[] args) {


        LinkedList<Hero> ll = new LinkedList<Hero>();

        ll.addLast(new Hero("hero1"));
        ll.addLast(new Hero("hero2"));
        ll.addLast(new Hero("hero3"));
        ll.addLast(new Hero("hero4"));

        System.out.println(ll);

        ll.addFirst(new Hero("heeroX"));
        System.out.println(ll);

        System.out.println(ll.getFirst());
        System.out.println(ll.getLast());

        System.out.println(ll);

        System.out.println(ll.removeFirst());
        System.out.println(ll.removeLast());
        System.out.println(ll);


        Queue<Hero> l2 = new LinkedList<Hero>();
        System.out.println("初始化队列！");
        l2.offer(new Hero("Hero1"));
        l2.offer(new Hero("Hero2"));
        l2.offer(new Hero("Hero3"));
        l2.offer(new Hero("Hero4"));
        l2.offer(new Hero("Hero5"));

        System.out.println(l2);

        System.out.println("第一个元素poll出来");
        Hero h =  l2.poll();
        System.out.println(h);


        h = l2.peek();
        System.out.println("看一看第一个但是不取出来");
        System.out.println(h);
        System.out.println("看看不会消失");
        System.out.println(l2);



    }
}

class Hero{
    public String name;
    public float hp;
    public int damage;

    public Hero(){}
    public Hero(String name){
        this.name = name;
    }
    public String toString(){
        return name;
    }
}